<?php namespace Home\Controller; 
use Think\Controller;

/**
 * Class 邮箱激活控制器
 * @package Home\Controller
 */
class MailController extends CommonController
{
	public function index()
	{	
		$id=$_SESSION['id'];
		$sql="select email,estate from user where id='{$id}'";
		$res=M('user')->query($sql);
		$res=current($res);
		$this->assign('info',$res);
		$this->display();
	}

	
    public function Verifyemail()
    {
        $sid=$_SESSION['id'];
        $gemail=$_GET['verify'];

        $sql="select email,estate from user where id='{$sid}'";
        $res=M('user')->query($sql);
        $res=current($res);
        $email=$res['email'];
        if (md5($email)!=$gemail) {
             $arr=array(
            	'error'=>0,
            	'info'=>'激活失败，邮箱不匹配，请检查你的邮箱账号是否己登录！'
            	);
             $this->assign('errorinfo',$arr);
        }else{
            $sql="update user set estate='1' where id='{$sid}'";
            M('user')->execute($sql);
            $sql="select email,estate from user where id='{$sid}'";
            $res=M('user')->query($sql);
            $res=current($res);
            $email=$res['email'];
        }
        $this->assign('email',$res);
        $this->display();
    }

}
?>